﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmoothStreaming.PerformanceTesting
{
    public class SmoothStreamChunk
    {
        StreamIndex _parentIndex = null;
        double _fragmentIndex;
        int _duration;
        int _bitrate;

        public SmoothStreamChunk(StreamIndex parentStreamIndex, double fragmentIndex, int duration, int bitrate)
        {
            _parentIndex = parentStreamIndex;
            _fragmentIndex = fragmentIndex;
            _bitrate = bitrate;
            _duration = duration;
        }

        public StreamIndex ParentStream { get { return _parentIndex; } }
        public double FragmentIndex { get { return _fragmentIndex; } }
        public double Duration { get { return _duration; } }
        public int Bitrate { get { return _bitrate; } }
        public string StreamType { get { return _parentIndex.StreamType; } }

        public string ChunkUrl { get { return GenerateChunkUrl(); } }

        private string GenerateChunkUrl()
        {
            return _parentIndex.Url.Replace("{start time}", _fragmentIndex.ToString()).Replace("{bitrate}", _bitrate.ToString());
        }

        public bool IsAudio { get { return StreamType.ToUpperInvariant() == "AUDIO"; } }
        public bool IsVideo { get { return StreamType.ToUpperInvariant() == "VIDEO"; } }
    }
}
